<template>
  <div class="home-banner">
    <XtxSlider :list="listRef" :date="5000" :flag="true"></XtxSlider>
  </div>
</template>

<script>
import { findBanner } from '@/api/home'
import { onMounted, ref } from 'vue'

export default {
  name: 'HomeBanner',
  setup () {
    const listRef = ref([])

    // 初始化调方法获取图片数据
    onMounted(() => {
      getList()
    })

    // 获取图片数据的方法
    async function getList () {
      // 掉接口获取数据赋值给本地
      const res = await findBanner()

      listRef.value = res.result
    }
    return {
      listRef
    }
  }
}
</script>

<style scoped lang='less'>
.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;
}
</style>
